<?php
namespace Dry\Base;

class Request {

    public $get = null;

    public $post = null;

    public $server = null;

    public $session = null;

    public function __construct()
    {
        $this->get = new RequestBase($_GET);
        $this->post = new RequestBase($_POST);
        $this->server = new RequestBase($_SERVER);
        $this->session = new SessionBase();
    }

    public function isPost()
    {
        return strtolower($this->server->get('REQUEST_METHOD'))=='post';
    }

    public function setOnceMessage($group, $key, $value)
    {
        $k = "system_once_{$group}";
        $list = $this->session->get($k, array());
        $list[$key] = $value;
        $this->session->set($k, $list);
    }

    public function getOnceMessage($group, $key = '')
    {
        $k = "system_once_{$group}";
        $result = $this->session->get($k, array());
        $this->session->remove($k);
        if(empty($result)){
            if($key!=''){
                return '';
            }
            return array();
        }
        else{
            if($key!=''){
                return $result[$key];
            }
            return $result;
        }
    }

}
?>
